
const fs = require('fs')


exports.readHtmlAsync = function(res,path){
    fs.readFile(path,'utf8',(err,data)=>{
        if(err) throw err
        res.writeHead(200,{'content-type':'text/html;charset=utf8'})
        res.write(data)
        res.end()
    })
}

exports.readJsonAsync = function(res,path){
    fs.readFile(path,'utf8',(err,data)=>{
        if(err) throw err
        res.writeHead(200,{'content-type':'application/json;charset=utf8'})
        res.write(data)
        res.end()
    })
}

exports.readImgAsync = function(res,path){
    fs.readFile(path,'binary',(err,data)=>{
        if(err) throw err
        res.writeHead(200,{'content-type':'image/jpeg;charset=utf8'})
        res.write(data,'binary')
        res.end()
    })
}